//
//  CustomCopySuccess.m
//  HuoBao
//
//  Created by 于会海 on 15/12/17.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "CustomCopySuccess.h"
@interface CustomCopySuccess()
{
    UIView*    bgview;
    UIView*    dangban;
    UILabel*   alertLabel;
}

@end
@implementation CustomCopySuccess
#define ScaleW  0.42667
#define ScaleH  0.08246
- (instancetype)initWithCopyBtnOraginY:(CGFloat)Y nameString:(NSString *)name{
    self = [super init];
    bgview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    bgview.backgroundColor = [UIColor blackColor];
    bgview.alpha = 0.3;
    [self addSubview:bgview];
    
    
    
    
    dangban = [[UIView alloc] initWithFrame:CGRectMake(0, 0,160,55)];
    dangban.backgroundColor = [LCCommon getColor:@"3d3e41"];
    dangban.center = CGPointMake(SCREEN_WIDTH/2, Y+75);
    dangban.alpha = 0.5;
    dangban.layer.cornerRadius = 4.0;
    [self addSubview:dangban];
    
    
    UIImage* image = [UIImage imageNamed:@"复制"];
    UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 18, image.size.width, image.size.height)];
    imageView.image = image;
    [dangban addSubview:imageView];
    
    
    alertLabel = [self LabelWithRect:CGRectMake(imageView.frame.origin.x+image.size.width+10, 0, dangban.size.width-50, dangban.size.height) textColor:[LCCommon getColor:@"ffffff"] textstr:name textfont:15 textstyle:NSTextAlignmentLeft];
    
    [dangban addSubview:alertLabel];
    return self;
}

-(UILabel *)LabelWithRect:(CGRect)rect textColor:(UIColor *)color textstr:(NSString *)str textfont:(int)font textstyle:(NSTextAlignment)aligment{
    UILabel *label = [[UILabel alloc] initWithFrame:rect];
    NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc]initWithString:str];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
    //设置行距
    [style setLineSpacing:10.0f];
    [attStr addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, [attStr length])];
    label.attributedText = attStr;
    label.text = str;
    label.textColor = color;
    label.font = [UIFont systemFontOfSize:font];
    label.textAlignment = aligment;
    label.numberOfLines = 0;
    return label;
}

-(void)makeLinewithRect:(CGRect)rect Color:(UIColor *)color addview:(UIView *)vi{
    UIView *line = [[UIView alloc]initWithFrame:rect];
    line.backgroundColor = color;
    [vi addSubview:line];
}

- (void)showSuccessAlertView{
    [UIView animateWithDuration:0.35 animations:^{
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        [[UIApplication sharedApplication].keyWindow addSubview:self];
        dangban.alpha = 1;
    }completion:^(BOOL finished) {
        [UIView animateWithDuration:0.35 delay:0.5 options:UIViewAnimationOptionLayoutSubviews animations:^{
            dangban.alpha = 0;
        } completion:^(BOOL finished) {
            [self removeFromSuperview];
        }];
        
    }];

}

@end
